﻿using System;

namespace 简单工厂设计模式
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Console.WriteLine("请输入你想要的笔记本品牌");
            Console.WriteLine("msi，ausu，hasee，lenovo");
            string brand = Console.ReadLine();
            NoteBook nb = GetNoteBook(brand);
            nb.SayHello();
            Console.ReadKey();
        }

        public static NoteBook GetNoteBook(string brand)
        {
            NoteBook nb = null;
            switch (brand)
            {
                case "msi":
                    nb = new MSI();
                    break;

                case "ausu":
                    nb = new AUSU();
                    break;

                case "hasee":
                    nb = new Hasee();
                    break;

                case "lenovo":
                    nb = new Lenovo();
                    break;

                default:
                    Console.WriteLine("没有{0}笔记本", brand);
                    break;
            }
            return nb;
        }
    }

    public abstract class NoteBook
    {
        public abstract void SayHello();
    }

    public class MSI : NoteBook
    {
        public override void SayHello()
        {
            Console.WriteLine("微星笔记本");
        }
    }

    public class AUSU : NoteBook
    {
        public override void SayHello()
        {
            Console.WriteLine("华硕笔记本");
        }
    }

    public class Hasee : NoteBook
    {
        public override void SayHello()
        {
            Console.WriteLine("神舟笔记本");
        }
    }

    public class Lenovo : NoteBook
    {
        public override void SayHello()
        {
            Console.WriteLine("联想笔记本");
        }
    }
}